//
//  BQFourButtonCell.m
//  BeeQuick
//
//  Created by mac on 16/11/20.
//  Copyright © 2016年 six_group. All rights reserved.
//

#import "BQFourButtonCell.h"
#import "BQHomeButtonView.h"


@interface BQFourButtonCell()

@end
@implementation BQFourButtonCell
{
    NSArray <BQHomeButtonView *>*_btnArr;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
//        [self setupUI];
    }
    return self;
}

//- (void)setupUI
//{
//    
//
//    
//}

- (void)setModelArr:(NSArray<BQActRowModel *> *)modelArr
{
    _modelArr = modelArr;
    
    NSMutableArray *arr = [NSMutableArray array];
    
    for (BQActRowModel *model in modelArr) {
        
        BQHomeButtonView *btnView = [[BQHomeButtonView alloc]init];
        
        [self.contentView addSubview:btnView];
        
        btnView.model = model.activity;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
        
        [btnView addGestureRecognizer:tap];
        
        [arr addObject:btnView];
    }
    
    _btnArr = arr.copy;
    
    [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
    
    [arr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(kScreenW, 80));
    }];
    
    
}



#pragma mark - View的点击方法

- (void)tap:(UITapGestureRecognizer*)tap
{
    BQHomeButtonView *View = (BQHomeButtonView*)tap.view;
    
    NSLog(@"%@",View.model.name);
    
}

-(void)setButtonWithImgArr:(NSArray*)imgArr andTitleArr:(NSArray *)titleArr
{

    
    NSMutableArray *arr = [NSMutableArray array];
    
    
    for(NSInteger i = 0 ; i < imgArr.count ; i++)
    {
        
        BQHomeButtonView *btnView = [[BQHomeButtonView alloc]init];
        
        [self.contentView addSubview:btnView];
        
        btnView.title = titleArr[i];
        btnView.img = imgArr[i];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
        
        [btnView addGestureRecognizer:tap];
        
        [arr addObject:btnView];
    }
    
    _btnArr = arr.copy;
    
    [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
    
    [arr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(kScreenW, 80));
    }];
    
    

}

@end
